﻿
using ProductFileGlobalDefs;

namespace ProductFileObjectModel
{
    public class OMUser
    {
        protected string m_UserName;
        protected string m_Password;
        protected eUserType m_UserType;

        public string UserName
        {
            get { return m_UserName; }
            set { m_UserName = value; }
        }

        public string Password
        {
            get { return m_Password; }
            set { m_Password = value; }
        }

        public eUserType UserType
        {
            get { return m_UserType; }
            set { m_UserType = value; }
        }

        public override string ToString()
        {
            return string.Format("UserName= {0}\nPassword= {1}\n UserType= {2}\n", 
                m_UserName, m_Password, ConvertUserNameToString(m_UserType));
        }

        public static string ConvertUserNameToString(eUserType typeToConvert)
        {
            string userTypeStr = string.Empty;
            switch (typeToConvert)
            {
                case eUserType.Admin:
                    userTypeStr = "Admin";
                    break;
                case eUserType.ExternalUser:
                    userTypeStr = "ExternalUser";
                    break;
                case eUserType.InternalUser:
                    userTypeStr = "InternalUser";
                    break;
                case eUserType.None:
                    userTypeStr = "None";
                    break;

            }
            return userTypeStr;
        }

        public static eUserType ConvertUserNameToEnum(string typeStrToConvert)
        {
            eUserType userType = eUserType.InternalUser;
            switch (typeStrToConvert)
            {
                case "Admin":
                    userType = eUserType.Admin;
                    break;
                case "ExternalUser":
                    userType = eUserType.ExternalUser;
                    break;
                case "InternalUser":
                    userType = eUserType.InternalUser;
                    break;
                case "None":
                    userType = eUserType.None;
                    break;

            }
            return userType;
        }

    }
}
